const WebSocket = require('ws');

var ws = new WebSocket('ws://localhost:8000/');
// 响应onmessage事件:
ws.on('open', function () {
    console.log(`[CLIENT] open()`);
    ws.send('CLient Hello!');
});

// 响应收到的消息:
ws.on('message', function (message) {
    console.log(`[CLIENT] Received: ${message}`);
})